/**
 * @a https://leetcode.cn/problems/palindrome-number/
 */

#include "common.h"

class Solution {
public:
    bool isPalindrome(int x) {
        if(x < 0 || (x % 10 == 0 x != 0)) return false;
        int latter_half = 0;
        while(x > latter_half){
            latter_half = latter_half * 10 + x % 10;
            x /= 10;
        }
        if(latter_half == x || latter_half / 10 == x) return true;
        return false;
    }
};

class Solution {
public:
    bool isPalindrome(int x) {
        if(x < 0 || (x % 10 == 0 && x != 0)) return false;
        int rvse = 0;
        int tmp = x;
        while(tmp){
            int digit = tmp % 10;
            rvse = rvse * 10 + digit;
            tmp /= 10;
        }
        return x == rvse;
    }
};